package com.cn.wanxi.service;

import com.cn.wanxi.dao.NavDao;
import com.cn.wanxi.model.NavModel;

import java.util.ArrayList;
import java.util.List;

public class NavService {
    public NavModel[] getNavModels() {

//        NavDao navModel = new NavDao();
//        navModel.setTitle("网站首页");
//        navModels[0] = navModel;
//        NavDao navModel1 = new NavDao();
//        navModel1.setTitle("公司简介");
//        navModels[1] = navModel1;
//        NavDao navModel2 = new NavDao();
//        navModel2.setTitle("新闻动态");
//        navModels[2] = navModel2;
//        数组的静态定义
        NavDao navDao = new NavDao();
        int leng = navDao.getTitles().length;
        NavModel[] navModels = new NavModel[leng];
        for (int i = 0; i < leng; i++) {
            NavModel navModel = new NavModel();
            navModel.setTitle(navDao.getTitles()[i]);
            navModels[i] = navModel;
        }
        return navModels;
    }


    public List<Object> getNavModelList() {
        List<Object> list = new ArrayList<>();
        NavDao navDao = new NavDao();
        int leng = navDao.getTitles().length;
        for (int i = 0; i < leng; i++) {
            NavModel navModel = new NavModel();
            navModel.setTitle(navDao.getTitles()[i]);
            navModel.setHref(navDao.getHrefs()[i]);
            list.add(navModel);
        }
        return list;
    }
}
